package com.yykj.backstage.all.controller;

import com.yykj.base.client.dto.template.ConsultationTemplateDTO;
import com.yykj.base.client.dto.template.ConsultationTemplateFieldDTO;
import com.yykj.base.client.dto.template.ConsultationTemplateFieldListDTO;
import com.yykj.base.client.dto.template.FormFieldDTO;
import com.yykj.base.client.feign.BaseFeignClient;
import com.yykj.common.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/api/backstage/all")
@Api(tags = "会诊模板相关接口")
@SuppressWarnings(value = "unchecked")
public class ConsultationTemplateController {

    @ApiOperation("会诊模板 -- 通用字段 -- 添加")
    @PostMapping("/form/field/edit")
    public ResultVO<FormFieldDTO> editBaseFormField(@RequestBody FormFieldDTO formFieldDTO) {
        return ResultVO.success(baseFeignClient.editFormField(formFieldDTO));
    }

    @ApiOperation("会诊模板 -- 通用字段 -- 删除")
    @DeleteMapping("/form/field/delete/{id}")
    public ResultVO deleteFormField(@PathVariable Integer id) {
        baseFeignClient.deleteFormField(id);
        return ResultVO.success();
    }

    @ApiOperation("会诊模板 -- 通用字段 -- 列表")
    @GetMapping("/form/field/common/list")
    public ResultVO<List<FormFieldDTO>> commonFormFieldList(){
        return ResultVO.success(baseFeignClient.commonFormFieldList());
    }

    @ApiOperation("会诊模板--添加修改")
    @PostMapping("/consultation/template/edit")
    public ResultVO<ConsultationTemplateDTO> editConsultationTemplate(@RequestBody ConsultationTemplateDTO consultationTemplateDTO) {
        return ResultVO.success(baseFeignClient.editConsultationTemplate(consultationTemplateDTO));
    }

    @ApiOperation("会诊模板--删除模板")
    @DeleteMapping("/consultation/template/delete/{id}")
    public ResultVO deleteConsultationTemplate(@PathVariable Integer id){
        baseFeignClient.deleteConsultationTemplate(id);
        return ResultVO.success();
    }

    @ApiOperation("会诊模板--列表")
    @GetMapping("/consultation/template/list")
    public ResultVO<List<ConsultationTemplateDTO>> listConsultationTemplate(){
        return ResultVO.success(baseFeignClient.listConsultationTemplate());
    }


    @ApiOperation("会诊模板--普通字段 -- 添加")
    @PostMapping("/consultation/template/field/edit")
    public ResultVO editConsultationTemplateFields(@RequestBody ConsultationTemplateFieldListDTO listDTO){
        baseFeignClient.editConsultationTemplateFields(listDTO);
        return ResultVO.success();
    }

    @ApiOperation("会诊模板--普通字段 -- 删除")
    @DeleteMapping("/consultation/template/field/delete/{id}")
    public ResultVO deleteConsultationTemplateFields(@PathVariable Integer id){
        baseFeignClient.deleteConsultationTemplateFields(id);
        return ResultVO.success();
    }

    @ApiOperation("会诊模板 -- 普通字段 -- 列表")
    @PostMapping("/consultation/template/field/list/{id}")
    public ResultVO<List<ConsultationTemplateFieldDTO>> listConsultationTemplateFields(@PathVariable Integer id){
        return ResultVO.success(baseFeignClient.listConsultationTemplateFields(id));
    }



    private BaseFeignClient baseFeignClient;

    @Autowired
    public void setBaseFeignClient(BaseFeignClient baseFeignClient) {
        this.baseFeignClient = baseFeignClient;
    }
}
